Expose InternalServer as a transport attribute in ServerImpl#12668
Expose InternalServer as a transport attribute in ServerImpl#12668vlcekmilan wants to merge 1 commit intogrpc:masterfrom
Conversation
|
|
6e9994a to
1e53d90
Compare
1e53d90 to
d49ab2f
Compare
|
Hello @ejona86, could you pls review this? |
That's internal. We're definitely not going to expose it directly. We'd have to do something indirectly.
How is a session established?
Is authentication an RPC, or part of TLS handshake? Or are you doing something with ServerTransportFilter? |
FWIW, predictable expiration could potentially be handled by maxConnectionAge(). But if sessions can be suddenly invalidated, that's quite a different thing. |
Is not part of the TLS handshake, auth happens inside grpc interceptCall(), which is invoked per RPC call, after the transportConnection is already established. |
|
Instead of a hard socket close, you might want to send an HTTP/2 GOAWAY. gRPC clients handle GOAWAY by transparently creating a new connection for the next request. To do that you can create a wrapper around Write a custom Include the custom Add a listener for handling the external session close in your server interceptor: Make sure to have a clean-up strategy for dead channels that may occur because the channel has been closed from the client side, and occupy unnecessary memory until the external session expires. If you must close the transport instead of sending GO_AWAY, you can obtain the channel with |
How does the client react to that? gRPC clients won't handle the connection close in any special way. If auth is a regular RPC, then you can handle the revocation in normal RPCs (e.g., responding UNAUTHENTICATED).
@kannanjgithub, those APIs are internal to gRPC. They should not be used by others. |

This change exposes the InternalServer as a transport-level attribute on ServerTransportListenerImpl, making it available to ServerTransportFilter implementations and downstream consumers via Attributes.
Changes
Why
We need access to the underlying ServerTransport from within a ServerInterceptor to force-close the transport connection when an external session expires.
In our use case, we have a ServerInterceptor that authenticates incoming RPCs against an external session management system. When a session isestablished, we register a close handler on it. If the external session is later invalidated or expires, the close handler fires and needs to shut down the underlying transport so the client is forced to reconnect and re-authenticate.
Currently, there is no way for a ServerInterceptor to access the transport layer to force-close a connection. The interceptor can reject individual RPCs via call.close(Status.UNAUTHENTICATED, ...), but it cannot terminate the transport itself.